//
//  ViewController.m
//  ApplePayDemo
//
//  Created by wulanzhou on 16/5/11.
//  Copyright © 2016年 wulanzhou. All rights reserved.
//

#import "ViewController.h"
#import "ApplePayManager.h" //苹果支付

@interface ViewController ()
@property (nonatomic,strong) ApplePayManager *payManager;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.payManager=[[ApplePayManager alloc] init];
    //设置App 内购买项目id (https://itunesconnect.apple.com)
    //CCMTV_VIP_012表示产品id,通过后台取得商品列表，选中一个需要购买的产品id
    self.payManager.appProductIDArray=[NSArray arrayWithObjects:@"CCMTV_VIP_012", nil];
    
    
    
    
    /** 重要说明==============================
     
     
     1.查看images文件夹下的图解说明进行操作
     2.在进行真机调试时，需要注销手机上的苹果appstore帐号,具体操作如下:设置＝＝》iTunes Store 与 App Store＝＝》找到帐号注销
     
     
     **/
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/**
 *  苹果支付
 *
 *  @param sender
 */
- (IBAction)startApplePayClick:(id)sender {
    
    //支付成功或失败的回调
    [self.payManager setPayApplyCompleted:^(BOOL success, NSString *errCode) {
        
        if(success){
            NSLog(@"支付成功");
        }else{
            NSLog(@"支付失败,原因=%@",errCode);
        }
        
    }];
    
    //订单编号(一般后台会生成)
    self.payManager.orderNo=@"21542312465";
    //苹果内购支付金额
    [self.payManager startPayWithMoneyStr:@"1148.0"];
    
}
@end
